import React, {Component} from 'react';
// import qs from 'querystring';


const data = [
    {id: '101', content: 'hello,Java'},
    {id: '102', content: 'hello,Golang'},
    {id: '103', content: 'hello,Python'}
]
/*js 数组查找api文档地址
https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf*/

class Detail extends Component {
    render() {
        // url restful 风格携带参数获取
        const {id, title} = this.props.match.params

        //search参数 获取
        // const {id,title} = qs.parse(this.props.location.search.slice(1));

        // state参数接收
        // const {id, title} = this.props.location.state || {}

        return (
            <div>
                <ul className='list-group'>
                    <li className='list-group-item'>ID:{id}</li>
                    <li className='list-group-item'>TITLE:{title}</li>
                    <li className='list-group-item'>CONTENT:{data.find(d => d.id === id).content}</li>
                </ul>
            </div>
        );
    }
}

export default Detail;